package com.bw.a1908.ui;

import android.view.View;

import com.blankj.utilcode.util.LogUtils;
import com.bw.a1908.R;
import com.bw.a1908.core.mvp.BaseActivity;
import com.bw.a1908.uitls.gfit.GiftBean;
import com.bw.a1908.uitls.gfit.display.DisplayController;
import com.bw.a1908.uitls.gfit.display.LiftDisplayView;
import com.bw.a1908.uitls.gfit.impl.GiftDefView;
import com.bw.a1908.uitls.gfit.impl.GiftRunStage;
import com.bw.a1908.uitls.gfit.impl.NumView;

public class TestActivity extends BaseActivity implements View.OnClickListener {

    private NumView numView;
    private GiftDefView defView;
    private LiftDisplayView displayView;

    @Override
    public int bandLayout() {
        return R.layout.activity_test;
    }

    @Override
    public void initView() {
        numView = findViewById(R.id.act_test_num_view);
        defView = findViewById(R.id.act_test_gift_view);
        displayView = findViewById(R.id.act_test_gift_dis_view);
    }

    @Override
    public void initData() {
        numView.showNum(1908);
        defView.onCreateView(new GiftBean(R.mipmap.cad));
        defView.onRunning(GiftRunStage.IN);

        testDisView();
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.btn_in:
                defView.onRunning(GiftRunStage.IN);
                break;
            case R.id.btn_re:
                defView.onRunning(GiftRunStage.ADD);
                break;
            case R.id.btn_out:
                defView.onRunning(GiftRunStage.OUT);
                break;
        }
    }

    private void testDisView() {
        for (int i = 0; i < 10; i++) {
            displayView.showView(new GiftBean("3-1", R.mipmap.cac, (long) 3000));
        }

    }

    public void testDisplay() {
        DisplayController controller = new DisplayController(3);

        controller.addGift(new GiftBean("3-1", (long) 3000));
        controller.addGift(new GiftBean("1-1", (long) 1000));
        controller.addGift(new GiftBean("2-1", (long) 2000));
        controller.addGift(new GiftBean("3-2", (long) 3000));

        controller.setOnGiftChanger(new DisplayController.OnGiftChanger() {
            @Override
            public void show(GiftBean bean) {
                LogUtils.d("show:" + bean.name);
            }

            @Override
            public void finish(GiftBean bean) {
                LogUtils.d("finish:" + bean.name);
            }
        });


    }
}
